// Binary to decimal

# include <iostream.h>
# include <conio.h>

class Dec2Bin {
  int decimal;
public:
  void getDecimal();
  void printBinary();
};

void Dec2Bin::getDecimal() {
  cout << "Enter decimal number:";
  cin >> decimal;
}

void Dec2Bin::printBinary() {
  cout << "Binary format: ";
  int array[100];
  int i = 0;
  int k;
  while(decimal) {
    array[i++] = decimal%2;
    decimal /= 2;
  }
  for(k = i-1; k >= 0; k--) {
    cout << array[k];
  }
}

void main() {
  clrscr();
  Dec2Bin db;
  db.getDecimal();
  db.printBinary();
  getch();
}